//
//  NSIDchangeType.m
//  jinyin
//
//  Created by liuyuzhe on 2020/3/26.
//

#import "NSIDchangeType.h"

@implementation NSIDchangeType


//空串
- (NSString*)filterOutUnqualifiedString:(NSString*)string
{
    NSString* name = [NSString stringWithFormat:@"%@",string];
    
    if ([name isEqualToString:@"<null>"] || [name isEqualToString:@"(null)"]) {
        return @"";
    }
    return name;
}

#pragma mark -
#pragma mark - 类型识别:将所有的NSNull类型转化成@""
-(id)changeTypes:(id)myObj
{
    if ([myObj isKindOfClass:[NSDictionary class]])
    {
        return [self nullDic:myObj];
    }
    else if([myObj isKindOfClass:[NSArray class]])
    {
        return [self nullArr:myObj];
    }
    else if([myObj isKindOfClass:[NSString class]])
    {
        return [self stringToString:myObj];
    }
    else if([myObj isKindOfClass:[NSNull class]])
    {
        return [self nullToString];
    }
    else
    {
        return myObj;
    }
}
//将NSDictionary中的Null类型的项目转化成@""
-(NSDictionary *)nullDic:(NSDictionary *)myDic
{
    NSArray *keyArr = [myDic allKeys];
    NSMutableDictionary *resDic = [[NSMutableDictionary alloc]init];
    for (int i = 0; i < keyArr.count; i ++)
    {
        id obj = [myDic objectForKey:keyArr[i]];
        
        obj = [self changeTypes:obj];
//        NSLog(@"key  %@ = %@",keyArr[i]obj);
        [resDic setObject:obj forKey:keyArr[i]];
    }
    return resDic;
}
//将NSArray中的Null类型的项目转化成@""
-(NSArray *)nullArr:(NSArray *)myArr
{
    NSMutableArray *resArr = [[NSMutableArray alloc] init];
    for (int i = 0; i < myArr.count; i ++)
    {
        id obj = myArr[i];
        
        obj = [self changeTypes:obj];
        
        [resArr addObject:obj];
    }
    return resArr;
}

//将NSString类型的原路返回
-(NSString *)stringToString:(NSString *)string
{
    
    if ([string isEqualToString:@"<null>"]) {
        return @"";
    }
    
    return string;
}

//将Null类型的项目转化成@""
-(NSString *)nullToString
{
    return @"";
}

-(CAGradientLayer *)setChangColorWithView:(UIView *)view andColorStart:(UIColor *)startColor andEndColor:(UIColor *)endColor{
    CAGradientLayer *gradLayer = [CAGradientLayer layer];
    gradLayer.frame = view.bounds;
    gradLayer.colors = @[(__bridge id)startColor.CGColor,(__bridge id)endColor.CGColor];
    gradLayer.startPoint = CGPointMake(0.0, 1.0);
    gradLayer.endPoint = CGPointMake(1.0, 1.0);
    return gradLayer;
   
}

-(NSString *)zongArrat:(NSArray *)zArray dqArray:(NSArray *)dqArray IndexPathCount:(NSInteger)count{
    NSMutableArray *titleArray = [[NSMutableArray alloc] initWithArray:zArray];
    [titleArray replaceObjectAtIndex:count withObject:dqArray];
    
    if (titleArray>0) {
//        NSMutableArray *jiaojiArray = [[NSMutableArray alloc] init];
        NSMutableSet *set1 = [NSMutableSet setWithArray:titleArray[0]];
        
        for (int i = 1; i<titleArray.count; i++) {
            NSMutableSet *set2 = [NSMutableSet setWithArray:titleArray[i]];
            [set1 intersectSet:set2];
            NSLog(@"--- %@ ",set1);
        }
        if (set1.count>0) {
            return [set1 anyObject];
        }
        return @"";
    }
    
    return @"";
}


-(NSString *)JSsuanjine:(NSString *)str{
    return @"";
}

@end
